package com.qb.common.ui.viewmodel

import androidx.lifecycle.MutableLiveData
import com.qb.baselibrary.basekotlin.BaseViewModel
import com.qb.common.bean.JokeBean
import com.qb.common.net.one.InjectorUtil

/**
 * @ClassName: CommonViewModel
 * @Description: 需要用到公共的都放这里，然后对应的viewmodel类都继承这个
 * @Author: Huimin
 * @Date: 2022/9/19 15:57
 */
open class CommonViewModel: BaseViewModel() {
    private val apiRepository by lazy { InjectorUtil.getApiServiceKotlin() }
    /**
     * 查询
     */
    fun phoneQuery(map:MutableMap<String,Any>): MutableLiveData<JokeBean> {
        var jokeBean = MutableLiveData<JokeBean>()
        launchGo({
            val result = apiRepository.phoneQuery(map)
            if (result.code==0){
                jokeBean.value = result
            }else{
                defUI.toastEvent.value = result.msg
            }
        },{
            defUI.toastEvent.value = it.msg
        },{},isShowDialog = true)
        return jokeBean
    }
}